<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of ccvKdtKnn</title>
  <meta name="keywords" content="ccvKdtKnn">
  <meta name="description" content="CCVKDTKNN searches the KD-Tree for the k-nearest neighbors for the input">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">caltech-image-search</a> &gt; ccvKdtKnn.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for caltech-image-search&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>ccvKdtKnn
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>CCVKDTKNN searches the KD-Tree for the k-nearest neighbors for the input</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [ids, dists] = ccvKdtKnn(kdt, kdtData, sData, k, tData) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> CCVKDTKNN searches the KD-Tree for the k-nearest neighbors for the input
 data
 
 INPUTS
 ------
 kdt       - the input kd-tree, output from CCVKDTCREATE
 kdtData   - the input data of the kd-tree, one column per point
             [ndimsXns]
 sData     - the data to search for
 k         - [1] how many nearest neighbors to return
 tData     - [] if given, use this data to traverse the Kd-tree, while
             using sData for actually computing distances and getting
             nearest neighbors

 OUTPUTS
 -------
 ids       - the sorted ids of the k-nearest neighbors. 0 means empty
             value, one column per input point [kXns]
 dists     - the distance to these nearest neighbors, Inf means empty
             value.

 See also <a href="ccvKdtClean.html" class="code" title="function ccvKdtClean(kdt)">ccvKdtClean</a> <a href="ccvKdtCreate.html" class="code" title="function kdt = ccvKdtCreate(data, ntrees, varrange, meanrange, maxdepth,minvar, cycle, dist, maxbins, sample, bitsperdim)">ccvKdtCreate</a></pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="DEMO.html" class="code" title="function DEMO">DEMO</a>	DEMO a demo script to show typical usage</li><li><a href="ccvAkmeansCreate.html" class="code" title="function [akmeans] = ccvAkmeansCreate(data, k, maxiter, type, ntrees,varrange, meanrange, maxdepth, minvar, cycle, dist, maxbins,sample, mex, matlabout, seed, verbose)">ccvAkmeansCreate</a>	CCVAKMEANS computes kmeans clustering on the input data using</li><li><a href="ccvAkmeansLookup.html" class="code" title="function [ids, dists] = ccvAkmeansLookup(akmeans, searchdata)">ccvAkmeansLookup</a>	AKMEANS computes kmeans clustering on the input data using approximate</li><li><a href="ccvBowGetWords.html" class="code" title="function dwords = ccvBowGetWords(words, data, locs, gws)">ccvBowGetWords</a>	CCVBOWGETWORDS computes word quantizations for the input data using the</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [ids, dists] = ccvKdtKnn(kdt, kdtData, sData, k, tData)</a>
0002 <span class="comment">% CCVKDTKNN searches the KD-Tree for the k-nearest neighbors for the input</span>
0003 <span class="comment">% data</span>
0004 <span class="comment">%</span>
0005 <span class="comment">% INPUTS</span>
0006 <span class="comment">% ------</span>
0007 <span class="comment">% kdt       - the input kd-tree, output from CCVKDTCREATE</span>
0008 <span class="comment">% kdtData   - the input data of the kd-tree, one column per point</span>
0009 <span class="comment">%             [ndimsXns]</span>
0010 <span class="comment">% sData     - the data to search for</span>
0011 <span class="comment">% k         - [1] how many nearest neighbors to return</span>
0012 <span class="comment">% tData     - [] if given, use this data to traverse the Kd-tree, while</span>
0013 <span class="comment">%             using sData for actually computing distances and getting</span>
0014 <span class="comment">%             nearest neighbors</span>
0015 <span class="comment">%</span>
0016 <span class="comment">% OUTPUTS</span>
0017 <span class="comment">% -------</span>
0018 <span class="comment">% ids       - the sorted ids of the k-nearest neighbors. 0 means empty</span>
0019 <span class="comment">%             value, one column per input point [kXns]</span>
0020 <span class="comment">% dists     - the distance to these nearest neighbors, Inf means empty</span>
0021 <span class="comment">%             value.</span>
0022 <span class="comment">%</span>
0023 <span class="comment">% See also ccvKdtClean ccvKdtCreate</span>
0024 <span class="comment">%</span>
0025 
0026 <span class="comment">% Author: Mohamed Aly &lt;malaa at vision d0t caltech d0t edu&gt;</span>
0027 <span class="comment">% Date: October 6, 2010</span>
0028 
0029 <span class="comment">%defaults</span>
0030 <span class="keyword">if</span> ~exist(<span class="string">'k'</span>,<span class="string">'var'</span>) || isempty(k), k = 1; <span class="keyword">end</span>;
0031 
0032 <span class="comment">%call the mex file</span>
0033 <span class="keyword">if</span> nargin&lt;=4
0034   [ids, dists] = mxKdtKnn(kdt, kdtData, sData, k);
0035 <span class="keyword">else</span>
0036   [ids, dists] = mxKdtKnn(kdt, kdtData, sData, k, tData);
0037 <span class="keyword">end</span>;
0038</pre></div>
<hr><address>Generated on Fri 05-Nov-2010 19:46:04 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>